\r\n";
mail('jim.rolt@googlemail.com', $subject, $error, $headers);
}
//include'memcache.php';
include'dataedit/sql.php';
$county = is_numeric($_GET['county']) && $_GET['county'] > 0 ? $_GET['county'] : 1;
$town = !empty($_GET['town']) ? $_GET['town'] : 'Worcester';
$qtown = !empty($_GET['town']) ? mysql_real_escape_string(preg_replace("/[-\s]/", "_",$_GET['town'])) : 'Worcester';
$sql = "SELECT SQL_CACHE Towns.ID, Towns.Description, clientpic, piclink, Towns.latitude, Towns.longitude, snippet, Towns.weather, EstDetails.Name, Quotes.quote, famousperson, famous.name FROM Towns
LEFT JOIN EstDetails ON EstDetails.RecordID = Towns.council
LEFT JOIN Quotes ON Quotes.townid = Towns.ID
LEFT JOIN famous ON famous.id = Quotes.famousperson
WHERE Towns.Name LIKE '".preg_replace("/[-\s]/", "_", $qtown)."' AND Towns.County = $county";
$details = mysql_query($sql)or mailjim("towndetails", "$sql\n".mysql_error());
$towndetails = mysql_fetch_object($details);
//$details = mysql_query_cache($sql);
//$towndetails = $details[0];
if(!empty($towndetails->clientpic)){
$sql = "SELECT Name FROM EstDetails WHERE RecordID = $towndetails->clientpic LIMIT 1";
$Ename = mysql_query($sql)or mailjim("Ename", "$sql\n".mysql_error());
$pname = mysql_fetch_object($Ename);
}
$events = mysql_query("SELECT SQL_CACHE eventid, event, events.month AS emonth, location, town, months.month, day, detailcounty, CountyName
FROM events
INNER JOIN months ON months.id = events.month
INNER JOIN CountyDetails ON CountyDetails.RecordID = events.county
WHERE county = $county
AND town LIKE '$qtown'
AND ( exactdate = '0000-00-00'
OR exactdate >= NOW() )
ORDER BY emonth, event");
$sql = "SELECT EstDetails.RecordID,
EstDetails.Name,
EstType,
EstTypeAlt,
EstType2,
EstType3,
Town,
EstDetails.description,
website,
EstDetails.email,
reviews.id AS Rid,
Details.DPrice
FROM featured
INNER JOIN EstablishmentType ON EstablishmentType.ID = featured.type
INNER JOIN EstDetails ON EstDetails.RecordID = featured.place AND EstDetails.Town = '$qtown' AND EstType = 1
LEFT JOIN Details ON Details.RecordID = EstDetails.RecordID
LEFT JOIN reviews ON EstDetails.RecordID = reviews.est AND reviews.display = 1 AND reviews.type = 1
WHERE featured.county = $county AND Town LIKE '$qtown'";
$poptemp1 = mysql_query($sql);
$sql = "SELECT EstDetails.RecordID,
EstDetails.Name,
EstType,
EstTypeAlt,
EstType2,
EstType3,
Town,
EstDetails.description,
website,
EstDetails.email,
CountyName,
CountyNameCut,
CountyDetails.CountryID,
CountyDetails.bcomregion,
reviews.id AS Rid,
Details.DPrice
FROM EstDetails
LEFT JOIN Details ON Details.RecordID = EstDetails.RecordID
INNER JOIN CountyDetails ON (County = CountyDetails.RecordID OR County2 = CountyDetails.RecordID)
LEFT JOIN reviews ON EstDetails.RecordID = reviews.est AND reviews.display = 1 AND reviews.type = 1
WHERE List = 1
AND (EstDetails.County = $county OR EstDetails.County2 = $county)
AND Town LIKE '$qtown' ORDER BY RAND() ";
$poptemp = mysql_query($sql);
$details = array();
$chid = array();
$count = 1;
$etarray = array('Hotel' => array(1,5,12), 'Bed and Breakfast' => array(2), 'Self Catering' => array(4), 'Budget' => array(7), 'hol' => array(15), 'Cottage' => array(20)); //types we want to put on the page
while($row = mysql_fetch_object($poptemp1)){
$details['Hotel'][$row->RecordID] = array('Name'=>$row->Name, 'Town'=>$row->Town, 'description'=>$row->description, 'website'=>$row->website, 'email'=>$row->email, 'Rid'=>$row->Rid, 'DPrice'=>$row->DPrice); //add establishment to details array
}
while($row = mysql_fetch_object($poptemp)){
if($count == 1){ //get county name
$CountyName = $row->CountyName;
$CountyNameCut = $row->CountyNameCut;
$CountryID = $row->CountryID;
$bcomregion = $row->bcomregion;
}
foreach($etarray as $key => $value){
if(in_array($row->EstType, $value) || in_array($row->EstType2, $value) || in_array($row->EstType3, $value) || in_array($row->EstTypeAlt, $value)){
$details[$key][$row->RecordID] = array('Name'=>$row->Name, 'Town'=>$row->Town, 'description'=>$row->description, 'website'=>$row->website, 'email'=>$row->email, 'Rid'=>$row->Rid, 'DPrice'=>$row->DPrice); //add establishment to details array
if(in_array($key, array('Hotel','Bed and Breakfast','Self Catering', 'Inn','Budget','Cottage')) && !in_array($row->RecordID, $chid)){
$count ++;
$chid[] = $row->RecordID;//count each establishment once only
}
}
}
}
//print_r($details);
if($count < 8 && $CountryID < 4){
$hotelids = array();
foreach($details as $a => $b){
foreach($b as $c => $d){
$hotelids[] = $c;
}
}
$hotelids = array_unique($hotelids);
$exclude = implode(',',$hotelids);
if($towndetails->latitude && $exclude > ''){
$sql = "SELECT EstDetails.RecordID, EstDetails.Name, EstDetails.Town, EstDetails.description, EstDetails.website, EstDetails.email, TYPE,
SQRT( POW( 69.1 * ( latitude - $towndetails->latitude ) , 2 ) + POW( 69.1 * ( $towndetails->longitude - longitude ) * COS( latitude / 57.3 ) , 2 ) ) AS distance
FROM EstDetails
INNER JOIN EstablishmentType ON EstablishmentType.ID = EstType
WHERE latitude IS NOT NULL
AND EstType IN(1,2,4,5,7)
AND RecordID NOT IN($exclude)
GROUP BY distance
ORDER BY distance ASC
LIMIT 10";
$others = mysql_query($sql);
// $others = mysql_query_cache($sql);
}
}
$sql = "SELECT SQL_CACHE id, LEFT(tips,49) AS tip FROM Towns WHERE Name = '$qtown' AND County = $county AND tips > ''";
$tips = mysql_query($sql)or mailjim("tips", "$sql\n".mysql_error());
$sql = "SELECT SQL_CACHE id FROM famousdates WHERE town = '$qtown' AND county = $county ";
$fd = mysql_query($sql)or mailjim("Famous dates", "$sql\n".mysql_error());
$query = "SELECT SQL_CACHE review FROM countyreviews
WHERE display = 1
AND county = $county
AND town = '$qtown'
ORDER BY id DESC LIMIT 1";
//echo $query.'
';
$view = mysql_query($query);
if(mysql_num_rows($view) == 1){
$vi = mysql_fetch_object($view);
$virep = '';
$description = explode(' ', $vi->review);
$dnum = (count($description) < 10) ? count($description) : 10;
for($i=0; $i<$dnum; $i++){$virep .= $description[$i].' ';}
}
if(!isset($details['Hotel']) && !isset($details['Inn'])){
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://information-britain.co.uk/bnbtowns.cfm?town=$town&county=$county");
exit();
}
$townpix = mysql_query("SELECT townpix.*, EstDetails.Name
FROM townpix
LEFT JOIN EstDetails ON EstDetails.RecordID = townpix.clientid
WHERE townpix.town LIKE '$qtown'
AND townpix.county = $county")or mailjim("townpix", mysql_error());
/*if(!function_exists('file_exists')){
function file_exists($path){
return (@fopen($path,"r")==true);
}
}*/
echo <<Hotels in $town. Online booking for $town hotels, $CountyName
EOT;
?>
output;
//include'featuredtownhotels.php';
//feature($county, $qtown);
include'adviva.txt';
include'burstmedia.txt';;
?>
";
if($trow->caption){echo"
$trow->caption";}
}
elseif(mysql_num_rows($townpix) > 0){
echo"
$trow->Name";
}
elseif($towndetails->clientpic > 0){
echo"
$pname->Name";
}
if(!empty($towndetails->postcode)){
$wday = date("D");
$wdate = date("j M");
$xml = simplexml_load_string($towndetails->weather, 'SimpleXMLElement', LIBXML_NOCDATA);
echo<<
5 day $town Weather |
$wday $wdate |
Max {$xml->Forecast[0]->maxtemp}°C Min {$xml->Forecast[0]->mintemp}°C |
{$xml->Forecast[0]->day->windspeed_mph} mph |
|
Provided by Weather2 |
EOT;
}
if($towndetails->latitude > 0){echo'
';}
if(!empty($towndetails->snippet)){
echo"
$towndetails->snippet.. \nRead More
";
}
if(isset($towndetails->quote)){
echo<<
"$towndetails->quote"
$towndetails->name
EOT;
}
if(mysql_num_rows($tips) > 0){
$tip = mysql_fetch_object($tips);
echo"
$town Tips:
\n\"$tip->tip...more";
}
echo'
';
if(isset($virep)){
echo"A Visitor's View
$virep...More
\n";
}
if(mysql_num_rows($events) > 0){
echo"$town Events
";
$monthcheck = '';
$counter = '';
while($row= mysql_fetch_object($events)){
if($monthcheck != $row->month){
echo"$row->month
";
$monthcheck =$row->month;
}
echo"$row->event
\n";
}
//echo'Add an Event';
}
?>
1 ? 'places' : 'place';
$join = '';
echo"
Hotels in $town - $count $places to stay
";
include'newbcombox.php';
newbox($town, $bcomregion);
$comma = '';
echo'
';
foreach($details as $key => $value){
switch($key){
case 'Bed and Breakfast':
echo"$comma B&Bs\n";
$comma=' | ';
$bnbpresent = 1;
break;
case 'Self Catering':
echo $count < 6 ? "$comma Self Catering\n":
"$comma Self Catering\n";
$comma = ' | ';
break;
case 'Budget':
echo $count < 6 ? "$comma Budget\n":
"$comma Budget\n";
$comma = ' | ';
break;
case 'Inn':
echo"$comma Inns\n";
$comma = ' | ';
break;
case 'Cottages':
echo"$comma Cottages\n";
$comma = ' | ';
break;
case 'hol':
echo"$comma Holiday Parks\n";
$comma = ' | ';
}
}
echo"$commaLate deals\n | $CountyName
";
include'hotelsummarynew.php';
if(isset($details['Hotel'])){showPlace('Hotel',10);}
if(isset($details['Inn'])){showplace('Inn',10);}
if(isset($details['Self Catering']) && $count < 6){
echo'
Self Catering
';
showplace('Self Catering');
}
if(isset($details['Budget']) && $count < 6){
echo'
Budget
';
showplace('Budget');
}
if(mysql_num_rows($others) > 0){
//if(!empty($others)){
echo"
Other Places to Stay near $town
\n";
$details = array();
while($row = mysql_fetch_object($others)){
// foreach($others as $row){
$dist = sprintf("%01.2f", $row->distance);
$details['Hotel'][$row->RecordID] = array('Name'=>$row->Name, 'Town'=>$row->Town, 'description'=>$row->description, 'website'=>$row->website, 'email'=>$row->email, 'distance'=>$dist); //add establishment to details array
}
showPlace('Hotel');
}
$townurl = urlencode($town);
if($count >= 11){echo"
Map of all our Hotels in $town
";}
include'dailyfeature.php';
?>